<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>加加减减</title>
    <script src="../vue.js"></script>
</head>
<body>
    <div id="app">
        <ul>
            <li v-for="(item, i) in arr">
                {{item}}
                <button @click="del(i)">删除</button>
            </li>
        </ul>
        <button @click="dev">生成</button>
    </div>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                arr: [1,5, 1]
            },
            methods:{
                // 生成随机数
                // 并渲染到页面
                dev(){
                    var number = Math.floor(Math.random() * 20)
                    this.arr.push(number)
                },
                del(i){
                    this.arr.splice(i,1);
                }
            }
        })
    </script>
</body>
</html>